package com.bss.service.impl;

import com.bss.pojo.Sales;
import com.bss.pojo.SalesExample;
import com.bss.service.SalesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 袁飞
 * @company 中原工学院
 * @create 2020-03-14-19:35
 */
@Service
public class SalesServiceImpl implements SalesService {
    @Autowired
    com.bss.dao.SalesMapper SalesMapper;
    public int addSales(Sales Sales) {
        return SalesMapper.insert(Sales);
    }

    public int updateSales(Sales Sales) {
        return SalesMapper.updateByPrimaryKeySelective(Sales);
    }

    public Sales findSalesById(Integer id) {
        return SalesMapper.selectByPrimaryKey(id);
    }

    public int deleteSalesById(Integer id) {
        return SalesMapper.deleteByPrimaryKey(id);
    }

    public List<Sales> findAll() {
        SalesExample SalesExample = new SalesExample();
        SalesExample.Criteria criteria = SalesExample.createCriteria();
        return SalesMapper.selectByExample(SalesExample);
    }

    public List<Sales> findSales(String saleName,String saleAddr,String saleProduct) {
        SalesExample SalesExample = new SalesExample();
        SalesExample.Criteria criteria = SalesExample.createCriteria();
        criteria.andSaleNameLike("%"+saleName+"%");
        criteria.andSaleAddrLike("%"+saleAddr+"%");
        criteria.andSaleProductLike("%"+saleProduct+"%");
        return SalesMapper.selectByExample(SalesExample);
    }

}
